import React from "react";
import { useEffect } from "react";
import { useParams, useLocation, useNavigate } from 'react-router-dom'
// path 动态参数部分
const Detail = () => {
    let id = null;
    // const navigate = useNavigate();
    let searchObj = new URLSearchParams(useLocation().search)
    const paramsObj = useParams();
    
    if (paramsObj?.id) {
        id = paramsObj.id
    } else {
        if (searchObj.get('id')) {
            id = searchObj.get('id')
        }
    }
    console.log(id, '---------')
    // useEffect(() => {
    //     if (!id) {
    //         navigate('/')
    //     }
    // }, [])
    
    // console.log(id)
    // console.log(window.location.href.search)
    // let paramsObj = new URLSearchParams(useLocation().search)
    // console.log(paramsObj.get('id'))
    // console.log(useLocation)
    return (
        <>
            Detail 
            {id}
        </>
    )
}

export default Detail